<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>北京西大校友产业生态圈联盟</title>

		<meta name="description" content="用户注册" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="/static/ace/assets/css/bootstrap.css" />
		<link rel="stylesheet" href="/static/ace/components/font-awesome/css/font-awesome.css" />

		<!-- text fonts -->
		<link rel="stylesheet" href="/static/ace/assets/css/ace-fonts.css" />

		<!-- ace styles -->
		<link rel="stylesheet" href="/static/ace/assets/css/ace.css" />


		<script src="/static/js/echarts.min.js"></script>
		<!--[if lte IE 9]>
		  <link rel="stylesheet" href="/static/ace/assets/css/ace-ie.css" />
		<![endif]-->

		<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

		<!--[if lte IE 8]>
		<script src="/static/ace/components/html5shiv/dist/html5shiv.min.js"></script>
		<script src="/static/ace/components/respond/dest/respond.min.js"></script>
		<![endif]-->
	</head>

	<body >
		<div class="main-container">
			<div class="main-content">

				<div style="padding-left: 18%;padding-right: 18%;padding-top: 40px;">
					<img width="140px" src="/static/logo.jpg">
					<span class=" lighter blue" style="font-size: 36px;">
							&nbsp;&nbsp;&nbsp;&nbsp;北京西大校友产业生态圈联盟
					</span>
				</div>

			<div class="row" style="padding-left: 18%;padding-right: 18%;padding-top: 20px;">
				<div class="col-xs-12" style="padding-left: 18%;padding-right: 18%;padding-top: 20px;">
						<div class="step-pane active widget-box" style="padding:30px 50px 25px 65px">
								<div class="form-horizontal" style="padding-left: 30%;padding-right: 30%;">
									<div class="form-group ">
										<div class="col-xs-12 col-sm-9">
											<div class="input-group" style="font-weight: bold">
													用户注册
											</div>
										</div>
									</div>
									<div class="form-group ">
										<div class="col-xs-12 col-sm-9">
											<div class="input-group">
												<span class="input-group-addon">
													<i class="ace-icon fa fa-phone"></i>
												</span>
												<input style="width:200px" type="tel" id="mobile" name="mobile" placeholder="请输入手机号"/>
											</div>
										</div>
									</div>

									<div class="space-10"></div>
									<div class="form-group ">
										<div class="col-xs-12 col-sm-9">
											<div class="input-group">
												<span class="input-group-addon" style="padding-right:9px">
													<i class="ace-icon fa fa-envelope"></i>
												</span>
												<input style="width:200px" type="email" id="email" placeholder="请输入邮箱"/>
											</div>
										</div>
									</div>

									<div class="space-10"></div>

									<div class="form-group">
										<div class="col-xs-12 col-sm-9">
											<div class="input-group ">
													<span class="input-group-addon" style="padding-right:14px">
														<i class="ace-icon fa fa-lock"></i>
													</span>
													<input style="width:200px" type="password" id="password" placeholder="请输入密码"/>
											</div>
										</div>
									</div>
									<div class="space-10"></div>
									<div class="form-group">
										<div class="col-xs-12 col-sm-9">
											<div class="input-group ">
												<span class="input-group-addon" style="padding-right:9px">
													<i class="ace-icon fa fa-retweet" ></i>
												</span>
												<input style="width:200px" type="password" id="password2" placeholder="请重复输入密码"/>
											</div>
										</div>
									</div>
									
									<div class="space-18"></div>
									<div class="form-group">
										<div class="col-xs-12 col-sm-9">
											<button  class="btn btn-info" style="width:235px" onclick="submitData()" id="register">
											注册
											</button>
										</div>
									</div>
									<div class="pull-right">
										<a href="/user/login" tabindex="6" target="_blank">
											返回登录</a>
									</div>
								</div>
								
							</div>
				</div>

				</div><!-- /.row -->
			</div><!-- /.main-content -->
		</div><!-- /.main-container -->
		<script src="/static/ace/components/jquery/dist/jquery.js"></script>
		<script src="/static/js/md5.js"></script>
		<script type="text/javascript">

		submitData = () => {
			// alert(hex_md5($('#password').val()));
			if (!/^1(3|4|5|7|8|6|9)\d{9}$/.test($('#mobile').val()) || ($('#mobile').val()).trim()==""){
				alert("请输入正确手机号");
				return
			}
			if (($('#password').val()).trim()==""){
				alert("请输入密码");
				return
			}
			if (($('#password2').val()).trim()==""){
				alert("请输入确认密码");
				return
			}
			if (($('#email').val()).trim()==""){
				alert("请输入邮箱");
				return
			}
			var payload = {
				mobile: $('#mobile').val(),
				password: hex_md5($('#password').val()),
				email:$('#email').val()
			};
			var opts = {
				method: 'POST',
				body: JSON.stringify(payload),
				headers: {
					'Content-Type': 'application/json'
				}
			};
			console.log(JSON.stringify(payload));
			let url = '/api/user/add';
			fetch(url, opts)
				.then(
					function(res) {
						if (res.ok) {
							//成功之后
						   return res.json();
						} else if (res.status === 500) {
							
						} else if (res.status === 406) {
							alert("该手机号已注册请返回登录");
						}
					},
					function(e) {
					}
				).then(resonseData => {
					if (resonseData) {
						window.location.href = "/user/userinfo/"+resonseData.id;
					}
				})
				.catch(error => {
				});
			}
			
		</script>

	</body>
</html>
